package com.woniu.woniu_bx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.woniu_bx.pojo.Role;
import org.apache.ibatis.annotations.*;

/**
 * @Description 角色表
 * @Author zhangjin
 * @Date 2022/8/27 16:19
 */
public interface RoleMapper extends BaseMapper<Role> {
    @Select("select count(*) from bx_role where name =#{name}")
    int getRoleNum(String name);

    @Update("update bx_role set status = 'N' where id =#{id}")
    void logicDel(int id);

    @Select("select * from bx_role")
    Page<Role> findAll(Page<Role> page);


    @Select("select * from bx_role where id =#{id}")
    @Results(id = "roleMap",value = {
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "id",property = "permList",many = @Many(select = "com.woniu.woniu_bx.mapper.PermMapper.getListByRoleID")),
            @Result(column = "id",property = "menuList",many = @Many(select = "com.woniu.woniu_bx.mapper.MenuMapper.getByRoleId"))
    })
    Role getRoleInfo(int id);

    @Delete("delete from bx_role where id=#{id}")
    void delRole(int id);
}
